package org.huntaway.spring.three;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.InputStreamResource;

public class LearnSpring3 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		LearnSpring3 ls3 = new LearnSpring3();
		ls3.section3_2();

	}

	private void section3_2() {
		try {
			InputStream is = new FileInputStream("beans.xml");
			InputStreamResource isr = new InputStreamResource(is);
			XmlBeanFactory factory = new XmlBeanFactory(isr);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		logEnd(1 + "...........");
		ClassPathResource res = new ClassPathResource("beans.xml");
		XmlBeanFactory factory2 = new XmlBeanFactory(res);
		logEnd(2 + "...........");
		ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(
				new String[] { "applicationContext.xml",
						"applicationContext-part2.xml" });
		// of course, an ApplicationContext is just a BeanFactory
		BeanFactory factory3 = (BeanFactory) appContext;

	}

	private void logEnd(String str) {
		System.out.println(str);
	}

}
